Repository navigation
crypto: foundation increment 1, primitives over libsodium, BearSSL, OpenSSL and ctaes - #4
Merged
Merged
Conversation
added 30 commits
November 18, 2026 13:12
…g secret; the wipe's reach is documented
…nt's changelog form asks: the lines of related changes are one
…ks of every result
…very public header, backends/sodium.hpp included, compiles in the lint's aggregate
…c asks, and clang-tidy's misc-explicit-constructor is silenced for it
doc/tables/crypto.json gains its families (gcm, aes_block, secp256k1): per family its algorithms, per backend the targets on which it has them, each claimed only where a test of the family's operations runs, constant time where it is not the backend's design, and the default per target with its reason. generate.py checks them and writes from them include/webcpp/crypto/detail/capabilities.hpp (the family and algorithm tags, detail::supported per cell and target, each family's refusal macro naming the backends that have it) and test/capabilities_test.cpp, which asserts every cell and makes every present one on each target. supports_v reads the table; ciphers::gcm, the AES block cipher and secp256k1's key pair name their family_type and name_type.
…e, and each refusal holds on its target crypto.json's old defaults list moves into families[].default, which states the defaults the code has now, each row claimed only where a test that fixes it runs; the defaults page, the backends pages and llms.txt read it. The refusal macros are written per target, so that a backend without the family on that target is refused rather than told to include a header. --check's printing is tested through checked(), a type keeps std:: as it is, the per-family constant time no longer restates the backend's, and the changelog's merged lines keep their facts.
… D32) Each family's default backend is chosen by WEBCPP_TARGET_* alone, whatever the program links, for the reason doc/tables/crypto.json gives (the owner's answers Q1 to Q4). generate.py writes detail/defaults.hpp from families[].default: default_backend_of<Family> with one specialisation per family that has a default, default_backend_t, and default_backend, AES-GCM's. AES-GCM's default is OpenSSL natively and BearSSL on WebAssembly; secp256k1's is libsecp256k1; the AES block cipher has none. config.hpp no longer chooses a default: WEBCPP_CRYPTO_DEFAULT_BACKEND_BEARSSL and _OPENSSL stop the build with the type to write (Q3). aes256_gcm.hpp includes its default's header only when it is linked; the family's primary engine, defined in gcm.hpp and aes.hpp with an empty primary state, is the generated refusal, which for the default not linked names the Jamfile line that links it and the type that names another backend. The refusal of an unknown backend now fires for an unknown type alone, and a one-target block opens with #ifdef. The default tests assert the fixed defaults with every backend linked, none, each alone and the plan's retired defines; default_selected and default_openssl_wasm become message tests of Q3's text, default_bearssl natively becomes gcm_default_openssl_not_linked, each with its MSVC case; two_defaults, no_backend_native, MSVC no_backend and default_two_files (its detect_mismatch) are gone. The examples that link BearSSL alone name it in the type.
… compilers, each compiler of a target once The check of two defaults on one target keyed on the free-text where (and before it linked), so one compiler written in two ways passed, and nothing checked that the rows of a target covered each compiler. A row now lists compilers by their names in crypto.json's compilers; check_families faults an unknown name, a compiler of a target in two rows, and one in none. The pages are unchanged.
…ion, so em++ runs its whole post-link optimisation secret, canary_read, canary_read_absent and wipe_objects_* were built at <optimization>speed in the debug variant, whose -g made em++ warn -Wlimited-postlink-optimizations ten times a lane: DWARF keeps binaryen to its limited passes. They read what an optimiser leaves, so on Emscripten they now drop the debug information (<toolset>emscripten:<debug-symbols>off) and wasm-opt runs in full, the stricter test; elsewhere nothing changes.
…he default's refusal says what a build without b2 links Review of Task 5', fix round 1. The use cases and five examples named BearSSL in the type, which natively steers a server on ARM to BearSSL's portable AES, the case OpenSSL's native default exists to avoid. They name aes256_gcm again and link its default on each target, OpenSSL natively and BearSSL on WebAssembly, through a rule of example/Jamfile that the guide shows; the guide states the cost of naming BearSSL natively where it shows that form. The never-called member functions of the primary engines return backend_failure, so a path the refusal missed fails closed. The needs message ends with what a build without b2 defines and links, from each backend's without_b2 in crypto.json. The other backend it names is the first of crypto.json's backends that has the family on the target when the program is built, never one decided at run time, in the family's shown name, which check_families requires where there is another backend. The fixes of no_backend_wasm and openssl_only_on_wasi match their message.
…target, generated with the defaults Review of Task 5', fix round 2. The guide taught a rule of the examples' Jamfile that called the internal webcpp-target module and could not be copied. generate.py now writes a block of build.jam, from families[].default as detail/defaults.hpp is, that gives each family with a default the alias /webcpp/crypto//<family>-default: its usage requirements link the default's library on each target, OpenSSL natively and BearSSL on WebAssembly for gcm-default. --check keeps the two from drifting. The examples link gcm-default; jamfile.adoc shows the Jamfile of the new fixture gcm_default, which builds and runs on all four targets, and the use cases name the line.
… clang-tidy's modernize-use-nodiscard asks
… 3, agree's own all-zero check), and its results [[nodiscard]] The conversion's main-subgroup check is now the only check that refuses two of the keys the test passes; a stand-in engine that does not refuse an all-zero shared secret shows that agree refuses it itself. The point (0, -1) is of order 2. The use case names curves::ed25519::keypair::x25519_secret in full.
…hout threads config.hpp defines WEBCPP_CRYPTO_HAS_THREADS by design D23's rule (natively BOOST_HAS_THREADS, on Emscripten -pthread, never on WASI, never with WEBCPP_CRYPTO_NO_THREADS). detail/heavy.hpp holds the refusal every heavy operation's async_ variant starts with, and detail::run_heavy, which posts the synchronous call to the program's executor and completes on the handler's associated executor. Increment 1 declares no heavy operation (design D32).
…25519 joins the curves table, its results are nodiscard, its wipes are tested, and llms.txt reads ph's sign and verify in their class
…, Ed25519ph's sign and verify included
…'s row, the generator refuses keys it does not know, and the changelog's lines fit the lint
…nd XChaCha20-Poly1305 on libsodium
… alone, and libsodium's engine passes an empty span's data as it is libsodium's detached decryptions check the tag alone when the output is null, and its ChaCha20 streams return at once on no byte, so the engine's static placeholder byte goes. The AEAD tests include what they use, and the ChaCha20-Poly1305 default's message gains its MSVC case.
…against RFC 8439, Wycheproof and libsodium BearSSL runs SSE2's ChaCha20 and ctmulq's Poly1305 where it has them and its constant-time portable code otherwise, the seam pinning the latter, and its tag is compared by equal; OpenSSL's EVP ChaCha20-Poly1305 runs GCM's sequence of AEAD controls on its own context. Both pass aead_checks.hpp, Wycheproof's 325 cases and agree with libsodium pairwise; ctaes's refusal and the default's now name the three backends. The additional data may touch the data but not overlap it, since BearSSL reads it after it encrypts.
…ha20-Poly1305 AEADs merged into libsodium's line
…sio for its async_ variants, and its test says why it runs the io_context
added 27 commits
November 18, 2026 19:37
…uration it peeks is gone or respelt The lane reads third_party/Jamfile's private .sodium-common, .sodium-posix and .sodium-linux and removes <define>HAVE_INLINE_ASM=1 by its spelling: an empty read, or one without that define, now stops the build at the Jamfile with what to update, rather than build libsodium with no configuration or with its inline assembly back in.
…ce, const, as clang-tidy asks
…he data generate.py takes the namespaces and the backends from crypto.json, writes each comparison table's speed from doc/performance.json and its measured constant time from the family's entries, refuses a fact about the world without a source naming its row, refuses a use case a program can follow without an example, lists every backend's facts and design, libsodium's with its sources, and its own suite, gives every API page its default per target, and gives each llms.txt entry its default and its use cases, and llms.txt the measured constant time. The ciphers table gains the ChaCha20 AEADs and the secret boxes; the rules, ChaCha's nonce and the shared secret that is not a key. The prose: the ciphers chapter's one rule of choice, ChaCha20-Poly1305's sourced constant time, limits, example and pitfalls; the chapter Choosing a backend, with the defaults, the stated heavy operations and the threads of a native build; X25519's open finding on wasip2 and webcpp::hash's HKDF; the hybrid chapter's choice and example; the file-sharing and peer-identity teaching sections, after age and libp2p; the attribution of libsodium's documentation, whose licence ships as LICENSE-LIBSODIUM-DOC.txt. Three examples: xchacha_seal, file_share and box_messages.
…on lists alone, so that one respelt stops the build too
…, backend and target, and the ciphers table fits the page crypto.json records, per family and backend, the targets and checkers of the constant-time lane (and a note where it runs part of a path), and the root's own paths; the comparison tables, the constant-time page's per-target columns and llms.txt are written from that one source, "not measured yet" where the lane runs nothing, and a lane entry or a finding the family does not claim is a fault. llms.txt gives a family without a default "none", and the AES block cipher's note on `aes256<>`. The ciphers table is cut into parts (AES, ChaCha20-Poly1305, secret boxes). The speed cells: each operation apart, three significant figures, the load said, an unknown backend a fault, and doc/performance.json refused unless built at variant=release. The nonce misuse and design cells are cited too; the file-sharing use case is the root's.
…the teaching sections on the specifications alone, file_share's refusals named A message cut into chunks is safe only with each chunk's number and a last-chunk flag under its tag, citing STREAM and libsodium's secretstream, neither of which this version offers; chacha.adoc and everyday.adoc said less, and aead.adoc's records now cite STREAM. The age and libp2p sections name their specifications only, libp2p's identity as one of its key types. file_share includes <span> and says which refusal is which.
…with its binding, and the constant-time note names X25519 The rulebook's library file now covers libsodium, the generated files and the open X25519 finding. everyday.adoc no longer says never to cut a file into boxes and then how to; the wasip2 cell's note names the family it covers, from the data and the generator, its test first.
…ndition, so that declared-lanes prints no b2 warning that tools/ci/matrix.py cannot read
…t checker alone, and a finding's note names its family only where the checker lists several
…en the backend fails, as their open does, shown on a stand-in engine that writes before it fails
…x keys wiped on destruction and on move, as the other backends' are
…oly1305 too: make, seal, good and failed opens and the destructor in the resource, on main and a second thread (spec 8.5)
…d PEM's default not linked, a backend's header not included, no backend of that name, Ed25519's one policy and secret<0>, prefixed as the others; MSVC cases for kx, box and these
…th a trailing comma, a row per designated member (readability-trailing-comma)
…message to a named string before printing it (the lint's fluent chains)
…am comment width)
…information on Emscripten, whose DWARF made em++ warn that it limited its post-link optimisation
…ane sizes' release builds on the four targets
…| split X25519's wasip2 finding over the curves table's cells
…and it is not set; X25519's native finding without DIT documented
… DIT, which wasmtime does not set
…f DIT on Apple silicon, the tables give the native finding to dudect alone, a failed read of the CPU's features fails, dudect_planted
…the constant-time Jamfile, X25519's note and page; dudect_planted builds and runs only the planted X25519 case
… after a bare <windows.h>, the tests' reserved.hpp reaches VirtualAlloc through detail/windows.hpp, and four tests rename the anonymous-namespace names that hid header parameters (C4459)
… nacl_message, which hid sealed_box's parameter (C4459 on MSVC)
…ute load 2.7 before, 3.4 after), confirmed by a second run within 3%, and the comparison tables regenerated from it
…ime Jamfile says DIT once
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this brings
webcpp::crypto's foundation, increment 1 (version 0.2's first part): primitives over C backends.
supports_vand the capability table per target.hybrid::box,sealed_box; failed seals and opens zero their data.kx_keypair), RFC 8410 SPKI and PKCS#8, PEM.secret<N>,equal,random_device, errors 13 to 20.Verification (local, on the final heads, before this PR)
-a, test and example: native 309, gcc-15 277, wasip2 268, wasip3 261, emscripten 202; 0 failed, 0 warnings.For the owner
seed,messageorpeer_public_key, built at /W4 /WX, can hit C4459 through a header parameter; the headers were left (no rename makes the class go away); the library's own tests are clean.Related PRs
libs/cryptogitlink to this branch's head, 1fc5140)🤖 Generated with Claude Code